//
//  YXJCDetailVC.m
//  Tunnel
//
//  Created by wbb on 2025/6/14.
//

#import "YXJCDetailVC.h"
#import "TYBaseTableViewCell.h"
#import "YXJCDetailEChartsView.h"
#import "CascadePickerView.h"
#import "BRDatePickerView.h"

@interface PointsModel : NSObject;
@property (nonatomic,copy) NSString * points;
@property (nonatomic,copy) NSString * pointsName;
@property (nonatomic,copy) NSString * value;

@end
@implementation PointsModel
@end
@interface HisDataModel : NSObject;
@property (nonatomic,copy) NSString * monitorValue;
@property (nonatomic,copy) NSString * saveTime;
@end
@implementation HisDataModel
-(NSString*)saveTime{
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat=@"yyyy-MM-dd HH:mm:ss";
    NSDate * saveTimeDate = [dateFormatter dateFromString:_saveTime];
    dateFormatter.dateFormat=@"HH:mm:ss";
    return [dateFormatter stringFromDate:saveTimeDate];

}
@end
@interface YXJCDetailCell : TYBaseTableViewCell

@end
@implementation YXJCDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self initUI];
    }
    return self;
}

- (void)initUI {
    UILabel *currentLab = nil;
    for (int i = 0; i<2; i++) {
        UILabel *headerLab = [[UILabel alloc] init];
        headerLab.text = @"测试";
        headerLab.tag = 10000000+i;
        headerLab.textColor = main_light_text_color_6;
        headerLab.textAlignment = NSTextAlignmentCenter;
        headerLab.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:headerLab];
        [headerLab mas_makeConstraints:^(MASConstraintMaker *make) {
            if (i == 0) {
                make.left.offset(0);
            }else {
                make.left.equalTo(currentLab.mas_right);
                make.width.equalTo(currentLab.mas_width);
            }
            make.top.bottom.offset(0);
            if (i == 1) {
                make.right.offset(0);
            }
        }];
        
        
        currentLab = headerLab;
    }
}
- (void)cellWithData:(id)data {
    [super cellWithData:data];
    HisDataModel * model = data;
    UILabel *lab1 = (UILabel *)[self.contentView viewWithTag:10000000];
    UILabel *lab2 = (UILabel *)[self.contentView viewWithTag:10000001];
    
    lab1.text = model.saveTime;
    lab2.text = model.monitorValue;

}
@end

@interface YXJCDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UIImageView * lineImgView;
@property (nonatomic, strong) UITableView * tableView;
@property (nonatomic, copy) NSArray * dataArr;
@property (nonatomic, strong) UIView * bottomBgView;
@property (nonatomic, strong) UIView * headerView;
@property (nonatomic, strong) YXJCDetailEChartsView *chartView;

@property (nonatomic, assign) NSInteger  currentTag;
@property (nonatomic, copy) NSArray *   pointsArr;
@property (nonatomic, strong) UILabel *   pointslabel;
@property (nonatomic, strong) PointsModel * selectPointsModel;
@property (nonatomic, strong) UIButton *btn1;
@property (nonatomic, strong) UIButton *btn2;
@property (nonatomic, strong) NSDate *selectDate;
@property (nonatomic,copy) NSArray * realDataArr;
@property (nonatomic,strong) UILabel * noLabel;
@property (nonatomic, strong) YXJCModel *model;

@end

@implementation YXJCDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"运行详情";
    self.selectDate = [NSDate date];
    [self initRequest];
}
-(void)initRequest{
    dispatch_group_t group = dispatch_group_create();
    dispatch_group_enter(group);
    kWEAK_SELF;
    [TYNetWorkTool getRequest:TYGetMeasuringPoints parameters:@{@"deviceId":self.ID} successBlock:^(BOOL success, NSDictionary * _Nonnull data, NSString * _Nonnull msg) {
        if(success) {
          weakSelf.pointsArr = [NSArray yy_modelArrayWithClass:PointsModel.class json:data[@"data"]];
            if(weakSelf.pointsArr.count > 0){
                weakSelf.selectPointsModel =  weakSelf.pointsArr[0];

            }
            dispatch_group_leave(group);

        }
    } failureBlock:^(NSString * _Nonnull description) {
        dispatch_group_leave(group);

    }];
    dispatch_group_enter(group);
    [TYNetWorkTool getRequest:TYGetRealData parameters:@{@"deviceId":self.ID} successBlock:^(BOOL success, NSDictionary * _Nonnull data, NSString * _Nonnull msg) {
        if(success) {
            NSData * jsonData = [data[@"data"] dataUsingEncoding:NSUTF8StringEncoding];
            self.realDataArr = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
            dispatch_group_leave(group);

        }
    } failureBlock:^(NSString * _Nonnull description) {
        dispatch_group_leave(group);

    }];
    
    dispatch_group_enter(group);
    [TYNetWorkTool postRequest:TYGetPaing parameters:@{
        @"id":self.ID,
      } successBlock:^(BOOL success, id  _Nonnull data, NSString * _Nonnull msg) {
        // 进入DispatchGroup，表示开始一个任务
        NSLog(@"-------1111-----------");
        if(success) {
           NSArray * array =  [NSArray yy_modelArrayWithClass:YXJCModel.class json:data[@"data"][@"list"]];
            if(array.count > 0 ){
                weakSelf.model = array[0];
            }
        }
        dispatch_group_leave(group);

        
    } failureBlock:^(NSString * _Nonnull description) {
        // 进入DispatchGroup，表示开始一个任务
        dispatch_group_leave(group);

    }];
    
    // 所有任务完成后的回调（在主线程执行，因为要更新UI）
    dispatch_group_notify(group, dispatch_get_main_queue(), ^{
        NSLog(@"-------ui-----------");
            for (NSDictionary * dict in self.realDataArr) {
                for (PointsModel * model in self.pointsArr) {
                    NSString * value = dict[model.points];
                    if(value){
                        model.value = [NSString stringWithFormat:@"%@",value] ;
                    }
                }
            }
            [weakSelf initUI];
            [weakSelf loadHistoryReq];
    });
    
}
-(void)loadHistoryReq{
    NSString *str = self.selectPointsModel.pointsName;
    if(str.length > 5){
        str = [NSString stringWithFormat:@"%@...",[str substringToIndex:5]];
    }
    [self.btn1 setTitle:str forState:UIControlStateNormal];
    [self.btn1 layoutButtonWithEdgeInsetsStyle:TYButtonEdgeInsetsStyleRight imageTitleSpace:5];

    kWEAK_SELF;
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
    dateFormatter.dateFormat=@"yyyy-MM-dd";
    
    [self.btn2 setTitle:[dateFormatter stringFromDate:self.selectDate] forState:UIControlStateNormal];
    dateFormatter.dateFormat=@"yyyyMMdd";

    [TYNetWorkTool postRequest:TYGetHisData parameters:@{
        @"monitorId":weakSelf.selectPointsModel.points?:@"",
        @"id":weakSelf.ID?:@"",
            @"startDate": [dateFormatter stringFromDate:weakSelf.selectDate]
        }
    successBlock:^(BOOL success, id  _Nonnull data, NSString * _Nonnull msg) {
        if(success){
            weakSelf.dataArr = [NSArray yy_modelArrayWithClass:HisDataModel.class json:data[@"data"]] ;
            [weakSelf.tableView  mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(weakSelf.headerView.mas_bottom);
                make.left.right.offset(0);
                make.height.offset(weakSelf.dataArr.count *24);
                make.bottom.offset(0);
            }];
            [weakSelf.tableView reloadData];
            if([weakSelf.chartView isHidden] == false){
                NSMutableArray * values = [NSMutableArray array];
                NSMutableArray * titles = [NSMutableArray array];
                for (HisDataModel * model in self.dataArr) {
                    if(model.saveTime){
                        [values addObject:model.monitorValue];
                        [titles addObject:model.saveTime];
                    }
                }
                [self.chartView setDataSource:values titles:titles];
            }
   
        }
        weakSelf.noLabel.hidden = true;
        if(weakSelf.dataArr.count == 0){
            weakSelf.noLabel.hidden = false;
            [weakSelf.noLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.offset(0);
                make.top.equalTo(weakSelf.headerView.mas_bottom);
                make.height.offset(40);
                make.bottom.offset(0);
            }];
        }
    } failureBlock:^(NSString * _Nonnull description) {
            
    }];
    
    
}
- (void)initUI{
    
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kSCREEN_WIDTH, self.view.height)];
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    
    UIView *topBgView = [[UIView alloc] init];
    topBgView.backgroundColor = [UIColor whiteColor];
    [scrollView addSubview:topBgView];
    topBgView.layer.shadowColor = [UIColor colorWithRed:156/255.0 green:175/255.0 blue:210/255.0 alpha:0.2].CGColor;
    topBgView.layer.shadowOffset = CGSizeMake(0,4);
    topBgView.layer.shadowOpacity = 1;
    topBgView.layer.shadowRadius = 8;
    topBgView.layer.cornerRadius = 7;
    
    
    UILabel  *titleLabel = [[UILabel alloc] init];
    titleLabel.font = [UIFont systemFontOfSize:17];
    titleLabel.textColor = main_text_color;
    titleLabel.text = @"基本信息";
    [topBgView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.top.offset(12);
    }];
    
    NSMutableArray *arr = @[@"所属系统", @"设备类型",@"设备编号",@"设备方向",@"设备位置",@"通讯状态",@"离线时间",@"离线原因",@"监测数据"].mutableCopy;
   
    NSMutableArray * valueArr = [NSMutableArray arrayWithArray:@[self.model.sysType,self.model.devName,self.model.ID,self.model.direction,self.model.pileNo,self.model.onOffStatus == 1?@"在线":@"离线",self.model.offtime?:@"",self.model.outCause?:@""]];
    
    if(self.model.onOffStatus == 1){
        [arr removeObjectsInRange:NSMakeRange(6, 2)];
        [valueArr removeObjectsInRange:NSMakeRange(6, 2)];
    }
    for (PointsModel* model in self.pointsArr) {
        [valueArr addObject:model.pointsName];
    }
    
    UIStackView *currentStackView = nil;
    for (int i = 0; i<valueArr.count; i++) {
        UIStackView *stackView1 = [[UIStackView alloc] init];
        stackView1.alignment = UIStackViewAlignmentTop; // 强制顶部对齐（关键属性）
        stackView1.distribution = UIStackViewDistributionFill; // 填充可用空间

        stackView1.spacing = 10;
        [topBgView addSubview:stackView1];
        [stackView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(15);
            make.right.mas_lessThanOrEqualTo(-15);
            if(i == 0){
                make.top.equalTo(titleLabel.mas_bottom).offset(5);
            }else {
                make.top.equalTo(currentStackView.mas_bottom);
            }
//            make.height.offset(20);
        }];
        
        UILabel *leftLab1 = [[UILabel alloc] init];
        if(i < arr.count){
            leftLab1.text = arr[i];
        }else{
            leftLab1.text = @"              ";
        }
        leftLab1.textColor = main_light_text_color_9;
        leftLab1.font = [UIFont systemFontOfSize:14];
        [stackView1 addArrangedSubview:leftLab1];

        UILabel * ssxtLab = [[UILabel alloc] init];
        ssxtLab.textAlignment = NSTextAlignmentLeft;
        if(i >= arr.count - 1){
            PointsModel * m = self.pointsArr[i - arr.count + 1];
            dispatch_async(dispatch_get_main_queue(), ^{
                NSString * str = [NSString stringWithFormat:@"%@ %@",m.pointsName,m.value];
                NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:str];
                NSRange range = NSMakeRange(str.length-m.value.length, m.value.length);
                [attributedString addAttribute:NSForegroundColorAttributeName value:hexColor(5490FF) range:range];
                ssxtLab.numberOfLines = 0;
                ssxtLab.attributedText = attributedString;
            });
            
        }else{
            ssxtLab.text = valueArr[i];
           
        }
 
        ssxtLab.tag = i+1000;
        ssxtLab.textColor = main_light_text_color_6;
            
            if([@"离线" isEqualToString:valueArr[i]] ){
                ssxtLab.textColor = [UIColor redColor];
            }
        ssxtLab.font = [UIFont systemFontOfSize:14];
        [stackView1 addArrangedSubview:ssxtLab];
        currentStackView = stackView1;
    }
    
    [topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(5);
        make.left.offset(12);
        make.right.offset(-12);
        make.bottom.equalTo(currentStackView.mas_bottom).offset(5);
        make.width.equalTo(scrollView.mas_width).offset(-24);
    }];
    
    
    
    UIView *bottomBgView = [[UIView alloc] init];
    bottomBgView.backgroundColor = [UIColor whiteColor];
    bottomBgView.clipsToBounds = YES;
    [scrollView addSubview:bottomBgView];
    self.bottomBgView = bottomBgView;
    bottomBgView.layer.shadowColor = [UIColor colorWithRed:156/255.0 green:175/255.0 blue:210/255.0 alpha:0.2].CGColor;
    bottomBgView.layer.shadowOffset = CGSizeMake(0,4);
    bottomBgView.layer.shadowOpacity = 1;
    bottomBgView.layer.shadowRadius = 8;
    bottomBgView.layer.cornerRadius = 7;
    
    UIButton *btn1 = [UIButton buttonWithTitle:@"CO" titleColor:main_light_text_color_6 font:[UIFont systemFontOfSize:14] imageName:@"select_icon"  target:self action:@selector(onType:)];
    btn1.tag = 10;
    btn1.backgroundColor = main_background_color;
    btn1.cornerRadius = 10;
    [bottomBgView addSubview:btn1];
    self.btn1 = btn1;
    [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.top.offset(12);
        make.width.mas_greaterThanOrEqualTo(76);
        make.width.mas_lessThanOrEqualTo(120);
        make.height.offset(20);
    }];
    
    UIButton *btn2 = [UIButton buttonWithTitle:@"2024-11-05" titleColor:main_light_text_color_6 font:[UIFont systemFontOfSize:14] imageName:@"select_icon"  target:self action:@selector(onType:)];
    btn2.backgroundColor = main_background_color;
    btn2.tag = 11;
    btn2.cornerRadius = 10;
    [bottomBgView addSubview:btn2];
    [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(btn1.mas_right).offset(10);
        make.top.offset(12);
        make.width.offset(96);
        make.height.offset(20);
    }];
    self.btn2 =btn2;
    [btn1 layoutButtonWithEdgeInsetsStyle:TYButtonEdgeInsetsStyleRight imageTitleSpace:5];
    [btn2 layoutButtonWithEdgeInsetsStyle:TYButtonEdgeInsetsStyleRight imageTitleSpace:5];
    
    UIButton *tabBtn1 = [UIButton buttonWithTitle:@"历史数据" titleColor:main_text_color font:[UIFont systemFontOfSize:14]  target:self action:@selector(onType:)];
    tabBtn1.tag = 12;
    [bottomBgView addSubview:tabBtn1];
    [tabBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.top.equalTo(btn1.mas_bottom).offset(10);
        make.width.equalTo(bottomBgView.mas_width).multipliedBy(0.5);
        make.height.offset(30);
    }];
    
    UIButton *tabBtn2 = [UIButton buttonWithTitle:@"运行趋势" titleColor:main_text_color font:[UIFont systemFontOfSize:14]  target:self action:@selector(onType:)];
    tabBtn2.tag = 13;
    [bottomBgView addSubview:tabBtn2];
    [tabBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(tabBtn1.mas_right);
        make.centerY.equalTo(tabBtn1.mas_centerY);
        make.width.equalTo(tabBtn1.mas_width);
        make.right.offset(0);
    }];
    
    UIImageView *lineImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gjtj_tab_icon"]];
    [bottomBgView addSubview:lineImgView];
    self.lineImgView = lineImgView;
    [lineImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(tabBtn1.mas_bottom).offset(0);
        make.centerX.equalTo(tabBtn1.mas_centerX);
        make.width.offset(20);
        make.height.offset(4);
    }];
    
    UIView *headerView = [[UIView alloc] init];
    headerView.backgroundColor = hexColor(EBF2FF);
    [bottomBgView addSubview:headerView];
    self.headerView = headerView;
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(4);
        make.right.offset(-4);
        make.top.equalTo(lineImgView.mas_bottom).offset(13);
        make.height.offset(24);
    }];
    
    NSArray *headerArr = @[@"时间", @"测点值"];
    UILabel *currentLab = nil;
    for (int i = 0; i<headerArr.count; i++) {
        UILabel *headerLab = [[UILabel alloc] init];
        headerLab.text = headerArr[i];
        headerLab.textColor = main_light_text_color_6;
        headerLab.textAlignment = NSTextAlignmentCenter;
        headerLab.font = [UIFont systemFontOfSize:14];
        
        [headerView addSubview:headerLab];
        [headerLab mas_makeConstraints:^(MASConstraintMaker *make) {
            if (i == 0) {
                make.left.offset(0);
            }else {
                make.left.equalTo(currentLab.mas_right);
                make.width.equalTo(currentLab.mas_width);
            }
            make.top.bottom.offset(0);
            if (i == headerArr.count -1) {
                make.right.offset(0);
            }
            
        }];
        
        
        currentLab = headerLab;
    }
    self.noLabel = [[UILabel alloc] init];
    self.noLabel.text = @"暂无数据";
    self.noLabel.font = [UIFont systemFontOfSize:14];
    self.noLabel.textAlignment = NSTextAlignmentCenter;
    self.noLabel.textColor = [UIColor blackColor];
    [self.tableView addSubview:self.noLabel];
    [bottomBgView addSubview:self.tableView];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(headerView.mas_bottom);
        make.left.right.offset(0);
        make.height.offset(30*34);
        make.bottom.offset(0);
    }];


    YXJCDetailEChartsView *chartView = [[YXJCDetailEChartsView alloc] init];
    [bottomBgView addSubview:chartView];
    self.chartView = chartView;
    self.chartView.hidden = true;
    
    [bottomBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topBgView.mas_bottom).offset(15);
        make.left.right.equalTo(topBgView);
        make.bottom.equalTo(scrollView.mas_bottom);
        make.width.equalTo(scrollView.mas_width).offset(-24);
    }];
    
    [scrollView layoutIfNeeded];
    
}
-(void)initDatePickerView{
    kWEAK_SELF
    // 1.创建日期选择器
    BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
    // 2.设置属性
    datePickerView.pickerMode = BRDatePickerModeYMD;
    datePickerView.title = @"选择年月日";
    datePickerView.selectDate = self.selectDate;
    NSDateComponents *comps = [[NSDateComponents alloc] init];
    [comps setMonth:-1];
    NSCalendar *calender = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];// NSGregorianCalendar

    NSDate *mDate = [calender dateByAddingComponents:comps toDate:[NSDate date] options:0];
    datePickerView.minDate = mDate;
    datePickerView.maxDate = [NSDate date];
    datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
        weakSelf.selectDate = selectDate;
        [weakSelf loadHistoryReq];
    };
    // 设置自定义样式
    BRPickerStyle *customStyle = [[BRPickerStyle alloc]init];
    datePickerView.pickerStyle = customStyle;

    // 3.显示
    [datePickerView show];
}
- (void)showPickerView:(NSInteger)tag {
    // 准备左侧数据
    // 创建并显示 picker
    NSMutableArray *leftData = [NSMutableArray array];
    for (PointsModel* model in self.pointsArr) {
        [leftData addObject:model.pointsName];
    }
    CascadePickerView* pickerView = [[CascadePickerView alloc] initWithLeftData:leftData columns:1];
    // 设置代理
//    pickerView.delegate = self;
    
    // 或者使用闭包
    kWEAK_SELF;
    pickerView.completionIndexBlock = ^(NSInteger leftIndex, NSInteger rightIndex) {
        weakSelf.selectPointsModel =  self.pointsArr[leftIndex];
        [weakSelf loadHistoryReq];
    };
    
    [pickerView show];
}
- (void)onType:(UIButton *)btn {
    NSInteger tag = btn.tag;
    
    if(tag == 10){// select1
        [self showPickerView:0];
    }else if (tag == 11){ // select2
        [self initDatePickerView];
    }else if (tag == 12){// tab1
        
        self.tableView.hidden = NO;
        self.chartView.hidden = YES;
        [self.tableView  mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView.mas_bottom);
            make.left.right.offset(0);
            make.height.offset(self.dataArr.count *24);
            make.bottom.offset(0);
        }];
        [self.chartView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.offset(0);
            make.height.offset(0);
        }];
        
        [self.lineImgView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(btn.mas_bottom).offset(0);
            make.centerX.equalTo(btn.mas_centerX);
            make.width.offset(20);
            make.height.offset(4);
        }];
        [self.headerView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.offset(24);
        }];
    }else if (tag == 13){// tab2
        self.tableView.hidden = YES;
        self.chartView.hidden = NO;
        [self.headerView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.height.offset(0);
        }];
        NSMutableArray * values = [NSMutableArray array];
        NSMutableArray * titles = [NSMutableArray array];
   

        for (HisDataModel * model in self.dataArr) {
            if(model.saveTime){
                [titles addObject:model.saveTime];
                [titles addObject:model.monitorValue];
            }
        }
        [self.chartView setDataSource:values titles:titles];
        [self.tableView  mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.offset(0);
            make.height.offset(0);
        }];
        [self.chartView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.headerView.mas_bottom);
            make.left.right.offset(0);
            make.height.offset(178);
            make.bottom.offset(0);
        }];
        
        [self.lineImgView mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(btn.mas_bottom).offset(0);
            make.centerX.equalTo(btn.mas_centerX);
            make.width.offset(20);
            make.height.offset(4);
        }];
    }
    
    self.currentTag = tag;
}
#pragma mark ---- UITableViewDelegate, UITableViewDataSource ----
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 24;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YXJCDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[YXJCDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    [cell cellWithData:self.dataArr[indexPath.row]];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
#pragma mark ---- lazy ----
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.scrollEnabled = NO;
    }
    return _tableView;
}
@end
